import { useRoutes,Navigate } from "react-router";
import React,{lazy} from 'react';
import Login from '../views/Login/Login'
import Home from '../views/Home/Home'
import Layout from '../components/layout/index'
import Room from '../views/Room/Room'
import Bulid from '../views/Bulid/Bulid'
import Go from '../views/Go/Go' 
import RoomList from "../views/RoomList/RoomList";
// const Room = lazy(()=>import('../views/Room/Room'))
// const Bulid = lazy(()=>import('../views/Bulid/Bulid'))

const frameOut = [
    {path:'/login',element:<Login />},
    {path:'/go',element:<Go />},
]

const frameIn = [
    {path:'index',element:<Home />},
    { path: 'setroom', element: <Room /> },
    { path: 'setbulid', element: <Bulid /> },
    { path:'roomlist', element:<RoomList/>},
    {path:'*',element:<Navigate to="index" />},
]

const Router = ()=>{
    let element = useRoutes([
        ...frameOut,
        {
            path:'/',
            element:<Layout />,
            children:frameIn
        },
        
    ])
    return element
}

export default Router